package test2

/**
  * Created by Bane.Shi.
  * Copyright MoenSun
  * User: Bane.Shi
  * Date: 2017/7/27
  * Time: 21:13
  */
object Test2 {

  def factorial(n:Int):Int = {

    @annotation.tailrec
    def go(n:Int,acc:Int):Int =
      if(n<=0) acc
      else go(n-1,n*acc)
    go(n,1)
  }

  def main(args:Array[String])= println(factorial(10))
}
